package cn.getech.data.development.controller.api;

import cn.getech.data.development.api.JobNodeInfoApi;
import cn.getech.data.development.dto.JobNodeInfoDto;
import cn.getech.data.development.dto.SysParamsDto;
import cn.getech.data.development.dto.SysParamsFileDto;
import cn.getech.data.development.entity.JobNodeInfo;
import cn.getech.data.development.service.JobNodeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @ClassName JobNodeInfoApiController
 * @Description TODO
 * @Author Getech
 * @Date 2020/12/24 11:46
 */
@RestController
public class JobNodeInfoApiController implements JobNodeInfoApi {

    @Autowired
    private JobNodeInfoService jobNodeInfoService;


    @Override
    public void cheackIsDrop(Integer jobNodeId) {
        jobNodeInfoService.cheackIsDrop(jobNodeId);
    }

    @Override
    public List<JobNodeInfoDto> selectListByIds(Set<Integer> jobIds) {
        return jobNodeInfoService.selectListByIds(jobIds);
    }

    @Override
    public JobNodeInfo getById(Integer jobNodeId) {
        return jobNodeInfoService.getDataById(jobNodeId);
    }

    @Override
    public String listRunSysparams(SysParamsDto sysParamsDto) {
        if(null == sysParamsDto){
            return "";
        }
        return jobNodeInfoService.listRunSysparams(sysParamsDto.getSql(),sysParamsDto.getJobNodeId());
    }

    @Override
    public String runShellNodes(String jobNodeId) {
        return jobNodeInfoService.runShellNodes(jobNodeId);
    }

    @Override
    public String listRunFileSysparams(SysParamsFileDto sysParamsFileDto) {
        if(null == sysParamsFileDto){
            return "";
        }

        return jobNodeInfoService.listRunSysparams(sysParamsFileDto.getMultipartFile(),sysParamsFileDto.getJobNodeId());
    }

    @Override
    public Long concurrentNum(String jobNodeId) {
        return jobNodeInfoService.concurrentNum(jobNodeId);
    }

    @Override
    public List<String> filePaths(String jobNodeId){
        return jobNodeInfoService.filePaths(jobNodeId);
    }
}
